package com.itheima.job1;

import java.util.Random;
import java.util.TreeSet;

public class test {
    public static void main(String[] args) {
        Random r = new Random();
        TreeSet<Integer> treeSet = new TreeSet<>((o1, o2) -> o1-o2);
        for (int i = 0; i < 10; i++) {
            int r1 = r.nextInt(51);
            treeSet.add(r1);
        }
        treeSet.forEach(val-> System.out.println(val));
        System.out.println("=============");
        //随机生成50~100之间的整数，按从大到小进行遍历
        TreeSet<Integer> treeSet1 = new TreeSet<>((o1, o2) -> o2-o1);
        for (int i = 0; i < 10; i++) {
            int r1 = r.nextInt(51)+50;
            treeSet1.add(r1);
        }
        treeSet1.forEach(val-> System.out.println(val));

    }



}
